package pso.gui.visualization;

import evolution.problem.OptimizationProblem;
import evolution.problem.ProblemConstraints;

public class HeatMapDataGenerator {
	public static double[][] generateHeatMapData(OptimizationProblem problem,
			int dimension) {
		double[][] result = new double[dimension][dimension];
		ProblemConstraints constraints = problem.getConstraints();
		double minArg = constraints.getMinArg();
		double maxArg = constraints.getMaxArg();

		double step = (maxArg - minArg) / dimension;

		double realX = minArg;
		for (int x = 0; x < dimension; x++, realX += step) {
			double realY = minArg;
			for (int y = 0; y < dimension; y++, realY += step) {
				result[x][y] = problem.getValue(new double[] { realX, realY });
			}
		}

		return result;
	}
}
